package com.chzn.component;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.beans.ConstructorProperties;
import java.lang.reflect.Constructor;

/**
 * @Description
 * @Author houchenkai
 * @Created Date: 2020/10/22 18:42
 * @ClassName
 */
@Component
//public class UserService implements InitializingBean {
public class UserService  {
//	@Autowired
//	private OrderService orderService;
//
//
//	@Override
//	public void afterPropertiesSet() throws Exception {
//		System.out.println("初始化");
//	}

//	public void test(){
//		System.out.println(orderService);
//	}

	public UserService() {
		System.out.println("userService无参构造");
	}
	@Autowired
//	@ConstructorProperties({"name1","name2"}) 指定构造方法参数名称
	public UserService(OrderService orderService) {
		System.out.println("userService注入orderService"+orderService);
	}

//	public OrderService getOrderService() {
//		return orderService;
//	}
//
//	public void setOrderService(OrderService orderService) {
//		this.orderService = orderService;
//	}

//	/**
//	 * Spring中默认实现的BeanPostProcessor   postProcessAfterInstantiation方法需返回true  @PostConstruct才生效
//	 * @see CommonAnnotationBeanPostProcessor
//	 * @PostConstruct  @PreDestroy
//	 */
//	@PostConstruct
//	//@PreDestroy
//	public void  initxxx(){
//		System.out.println("-------初始化-----------");
//	}

}
